/*
 * Copyright (C) 2008-2012  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#ifndef _etypes_h
#define _etypes_h

#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>

#ifndef __WORDSIZE
#  define __WORDSIZE		WORDSIZE
#endif
#ifndef __BYTE_ORDER
#  define __BYTE_ORDER		BYTE_ORDER
#endif
#ifndef __LITTLE_ENDIAN
#  define __LITTLE_ENDIAN	LITTLE_ENDIAN
#endif
#ifndef __BIG_ENDIAN
#  define __BIG_ENDIAN		BIG_ENDIAN
#endif

/* Native types */
typedef signed char		eint8_t;
typedef unsigned char		euint8_t;
typedef signed short		eint16_t;
typedef unsigned short		euint16_t;
typedef signed int		eint32_t;
typedef unsigned int		euint32_t;
#if __WORDSIZE == 32
#  define HALFSHIFT		15
#  define SGN_MASK		0x7fffffff
#  define MININT		0x80000000
typedef signed long long	eint64_t;
typedef unsigned long long	euint64_t;
#  define ehalf_t		eint16_t
#  define euhalf_t		euint16_t
#  define eword_t		eint32_t
#  define euword_t		euint32_t
#else
#  define HALFSHIFT		31
#  define SGN_MASK		0x7fffffffffffffff
#  define MININT		0x8000000000000000
typedef signed long		eint64_t;
typedef unsigned long		euint64_t;
#  define ehalf_t		eint32_t
#  define euhalf_t		euint32_t
#  define eword_t		eint64_t
#  define euword_t		euint64_t
#endif

typedef eint32_t		ebool_t;

typedef float			efloat32_t;
typedef double			efloat64_t;
typedef void*			eobject_t;

#define efloat_t		efloat64_t
#define esingle_t		efloat32_t

typedef struct rat		rat_t;
typedef struct rat*		erat_t;
typedef __mpz_struct*		empz_t;
typedef __mpq_struct*		empq_t;
typedef __mpfr_struct*		empr_t;
typedef __mpf_struct*		empf_t;

typedef complex double		ecdd_t;
typedef __cqq_struct*		ecqq_t;
typedef __mpc_struct*		empc_t;

typedef struct ertti		ertti_t;

typedef enum etype		etype_t;
typedef enum etoken		etoken_t;
typedef enum etagtype		etagtype_t;
typedef struct evector		evector_t;
typedef struct estream		estream_t;
typedef struct einput		einput_t;
typedef struct ethread		ethread_t;
typedef struct eentry		eentry_t;
typedef struct ehash		ehash_t;
typedef struct esymbol		esymbol_t;
typedef struct eformat		eformat_t;
typedef struct enote		enote_t;

typedef struct east		east_t;
typedef struct etag		etag_t;
typedef struct ebasic		ebasic_t;
typedef struct erecord		erecord_t;
typedef struct erecord		enamespace_t;
typedef struct efunction	efunction_t;
typedef struct evalue		evalue_t;

/*
 * Prototypes
 */
extern void
etype_ast(east_t *ast);

extern etype_t
etag_to_type(etag_t *tag);

#endif /* _etypes_h */
